package com.base.rq.ctr;

import android.app.Activity;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

import com.base.rq.LOG;
import com.base.rq.R;
import com.rq.app_base.android.event.OnClick;
import com.rq.app_base.use.BaseController;

import androidx.annotation.RequiresApi;
import aoto.com.mylibrary.MediaTTSManager;
import aoto.com.mylibrary.WhyTTS;
import ecomm.lib_comm.permission.PermissionUtil;

/**
 * @author RQ
 * date    2021-07-12 9:01
 */
@RequiresApi(api = Build.VERSION_CODES.M)
public class MainController extends BaseController implements View.OnClickListener,
                                                              PermissionUtil.OnPermissionListener {
  @Override
  protected int getLayoutId() {
    return R.layout.activity_main;
  }

  WhyTTS whyTTS;

  @Override
  public void onViewCreated(Bundle savedInstanceState) {
    super.onViewCreated(savedInstanceState);
    setData2View(R.id.tv_bottom, System.currentTimeMillis() + "");
    whyTTS = MediaTTSManager.getInstance(getContext());
    whyTTS.resume();
    //    Speaker.instance(getContext()).init();
  }

  @Override
  @OnClick({R.id.tv_bottom})
  public void onClick(View v) {
    LOG.e("MainController", "onClick.48:");
    if (v.getId() == R.id.tv_bottom) {
      LOG.e("MainController", "onClick.48:");
      //      open(MainController2.class, "123", "456");
      openWith(MainController2.class, CODE, "123", "456");
    }
  }

  @Override
  protected boolean onResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == Activity.RESULT_OK) {
      LOG.e("MainController", "onResult.58:" + getPass(0, data));
      return true;
    }
    return super.onResult(requestCode, resultCode, data);
  }

  public static final int CODE = 0x00301;

  @Override
  public void onPermissionOk() {
    Toast.makeText(getContext(), "点击", Toast.LENGTH_LONG).show();
    //    whyTTS.speak("中文播报。。。123");
    //    Speaker.instance(getContext()).speak("中文播报12344");
  }

}
